package com.rgs.base.rocketmq.config;

import com.rgs.base.rocketmq.RocketMqProducer;
import com.rgs.base.rocketmq.def.DefRocketProducerImpl;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

import javax.annotation.Resource;

/**
 * @author Ren Gaoshuai
 * @date 2022-03-08 16:50
 **/
@SpringBootConfiguration
@EnableConfigurationProperties(RocketMqSource.class)
@ConditionalOnProperty(prefix = "rgs.rocket", name = "enable", havingValue = "true")
@Import(RocketMqConfigConsumerListen.class)
public class RocketMqAutoConfig {

    @Resource
    RocketMqSource rocketMqSource;

    @Bean
    public RocketMqProducer rocketMqProducer() {
        return new DefRocketProducerImpl(rocketMqSource);
    }
}
